<html>
<head><meta charset="utf-8"><title>what is the name of this pattern · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/what.20is.20the.20name.20of.20this.20pattern.html">what is the name of this pattern</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218796857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/what%20is%20the%20name%20of%20this%20pattern/near/218796857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/what.20is.20the.20name.20of.20this.20pattern.html#218796857">(Dec 04 2020 at 05:54)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="cp">#[inline]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">with_ordinal0</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">ordinal0</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="n">NaiveDateTime</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="n">date</span><span class="p">.</span><span class="n">with_ordinal0</span><span class="p">(</span><span class="n">ordinal0</span><span class="p">).</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">d</span><span class="o">|</span><span class="w"> </span><span class="n">NaiveDateTime</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">date</span>: <span class="nc">d</span><span class="p">,</span><span class="w"> </span><span class="o">..*</span><span class="bp">self</span><span class="w"> </span><span class="p">})</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="218796874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/what%20is%20the%20name%20of%20this%20pattern/near/218796874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/what.20is.20the.20name.20of.20this.20pattern.html#218796874">(Dec 04 2020 at 05:55)</a>:</h4>
<p>What is the <code>..*self</code> idiom/pattern called?</p>



<a name="218797006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/what%20is%20the%20name%20of%20this%20pattern/near/218797006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/what.20is.20the.20name.20of.20this.20pattern.html#218797006">(Dec 04 2020 at 05:58)</a>:</h4>
<p>Found it, it's called <code>struct update syntax</code></p>



<a name="218797014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/what%20is%20the%20name%20of%20this%20pattern/near/218797014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/what.20is.20the.20name.20of.20this.20pattern.html#218797014">(Dec 04 2020 at 05:59)</a>:</h4>
<p><a href="https://doc.rust-lang.org/book/ch05-01-defining-structs.html">https://doc.rust-lang.org/book/ch05-01-defining-structs.html</a></p>



<a name="218800249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/what%20is%20the%20name%20of%20this%20pattern/near/218800249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/what.20is.20the.20name.20of.20this.20pattern.html#218800249">(Dec 04 2020 at 07:17)</a>:</h4>
<p>Also often known as FRU, <em>functional record update</em>.</p>



<a name="218800399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/what%20is%20the%20name%20of%20this%20pattern/near/218800399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/what.20is.20the.20name.20of.20this.20pattern.html#218800399">(Dec 04 2020 at 07:20)</a>:</h4>
<p>good to know, thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>